package cn.antho.basic.config;

import cn.antho.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截器配置类
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 添加我们的登录拦截器
                .addPathPatterns("/**") // 设置拦截所有
                .excludePathPatterns( // 设置拦截器放行路径
                        "/login/**", // 放行登录相关接口
                        "/verifyCode/**", // 放行验证码相关接口
                        "/fastdfs/**", // 放行fastdfs相关接口
                        "/shop/settlement", // 放行店铺入驻相关接口
                        "/user/register/**", // 放行手机注册相关接口
                        "/shop/active/**" // 放行店铺激活相关接口
                );
    }
}
